#include <iostream>
#include <vector>
#include <algorithm>
#define MO 1e6+10
//#define int long long
using namespace std;
vector<int> arr(MO);
int N,M;
bool count(int x)
{
	//cout<<"mid:"<<x<<endl;
	long long sum=0;
	for(int i=0;i<N;i++)
	{
		int temp=arr[i]-x;
		if(temp>0)
		sum+=temp;
	}
	return sum<M;
}
int main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
	cin>>arr[i];
	sort(arr.begin(),arr.begin()+N);
	//for(int i=0;i<N;i++)
	//cout<<arr[i]<<' ';
	int left=0;
	int right=arr[N-1];

	while(right>left)
	{
		//cout<<"left:"<<left<<endl;
		//cout<<"right:"<<right<<endl;
		int mid=left+((right-left+1)>>1);
		if(count(mid))//sum<M
		right=mid-1;
		else
		left=mid;
	}
	cout<<left<<endl;
	return 0;
}
